package com.ccys.db.mapper;

import com.ccys.db.dto.consultation.*;
import com.ccys.db.dto.member.AppointmentCancellationReasonsDto;
import com.ccys.db.dto.member.CancelAppointmentBookingDto;
import com.ccys.db.dto.member.MemberCancelAppointmentDto;
import com.ccys.db.dto.member.PaymentInstructionDto;
import com.ccys.db.entity.TblBooking;
import com.ccys.db.entity.TblMember;
import com.ccys.db.vo.app.callStandByScreen.CheckConsultReadyVo;
import com.ccys.db.vo.app.callStandByScreen.MedicalServiceMakeVo;
import com.ccys.db.vo.app.historyScreen.MemberBookingMakeVo;
import com.ccys.db.vo.app.splashscreen.AllergiesMakeVo;
import com.ccys.db.vo.app.splashscreen.MedicationReactionsMakeVo;
import com.ccys.db.vo.consultation.*;
import com.ccys.db.vo.doctor.consultationHistory.BookingsMakeVo;
import com.ccys.db.vo.doctor.doctorConsultStage.GetComboboxUpConsultVo;
import com.ccys.db.vo.doctor.login.ProfileVo;
import com.ccys.db.vo.doctor.passHistoryConsultants.ConsultantsMakeVo;
import com.ccys.db.vo.doctor.passHistoryConsultants.DiagnosisMakeVo;
import com.ccys.db.vo.doctor.passHistoryConsultants.GetPassHistoryConsultantsMakeVo;
import com.ccys.db.vo.doctor.passHistoryConsultants.HistoryConsultantsInitMakeVo;
import com.ccys.db.vo.doctor.patientHistory.*;
import com.ccys.db.vo.member.CancellationReasonVO;
import com.ccys.db.vo.member.MemberCancelAppointmentVO;
import com.ccys.db.vo.member.PaymentMethodVO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * Created by Mybatis Generator on 2023/12/27
 */
public interface TblBookingMapper extends Mapper<TblBooking>, MySqlMapper<TblBooking> {
    /**
     * @description 查询预约管理列表
     * @date 2023/12/28
     * @author cloud fly
     */
    List<BookingAppointmentWebVO> listObjectsCms(BookingDTO dto);

    /**
     * @description 查询预约管理详情
     * @date 2023/12/28
     * @author cloud fly
     */
    BookingAppointmentDetailWebVO getBookingAppointmentDetail(BookingDTO dto);

    List<ConsultationPageQueryVo> findConsultationBasePage(ConsultationPageQueryDto dto);

    /**
     * 医生info的ConsultationList分页查询
     *
     * @param dto
     * @return
     */
    List<DoctorInfoConsultationListPageVo> findPageDoctorInfoConsultationList(DoctorInfoConsultationListPageDto dto);

    /**
     * 根据医生ID查询医生所有收入
     *
     * @param doctorId
     * @return
     */
    BigDecimal findTotalEarningByDoctorId(@Param("doctorId") String doctorId);

    /**
     * 咨询图 - 问诊列表和医生info都使用这个接口
     *
     * @param dto
     * @return
     */
    List<ConsultationGraphMake> findConsultationGraph(ConsultationGraphQueryDto dto);

    BigDecimal findTotalPaymentByMemId(@Param("memId") String memId);

    /**
     * 问诊页面的On going consultations里面的分组查询
     *
     * @return
     */
    List<ConsultationGroupMake> findConsultationGroupList();

    /**
     * consultaionList的info里面的base里面的MedicationCertificationPdf
     *
     * @param bookingId booking_id
     * @return
     */
    MedicationCertificationPdfVo getMedicationCertificationPdfData(@Param("bookingId") String bookingId);

    String getMasterDataFindCount(@Param("memberId") String memberId);

    CheckConsultReadyVo appFindById(@Param("bookingId") String bookingId);

    List<MemberBookingMakeVo> findPageByMemberId(@Param("pageIndex") Integer pageIndex, @Param("pageSize") Integer pageSize, @Param("memberId") String memberId);

    /**
     * @description 查询booking 的取消理由
     * @date 2024/1/29
     * @author cloud fly
     */
    List<CancellationReasonVO> getAppointmentCancellationReasons(AppointmentCancellationReasonsDto dto);

    /**
     * @description 查询预约取消相关信息
     * @date 2024/1/29
     * @author cloud fly
     */
    MemberCancelAppointmentVO getCancelAppointmentBooking(CancelAppointmentBookingDto dto);

    /**
     * @description 更新用户取消预约
     * @date 2024/1/29
     * @author cloud fly
     */
    int updateCancelAppointmentBooking(MemberCancelAppointmentDto memberCancelAppointmentDto);


    Integer getCountOfWaitingApproval(@Param("patientCountryOfResidence") String patientCountryOfResidence, @Param("doctorCountryOfResidence") String doctorCountryOfResidence);

    /**
     * @description 获取支付信息
     * @date 2024/2/5
     * @author cloud fly
     */
    List<PaymentMethodVO> getPaymentMethodVO(PaymentInstructionDto dto);

    List<BloodPressuresVo> getBloodPressureHistory(@Param("memberId") String memberId);

    TblMember findMemberByBookingId(@Param("bookingId") String bookingId);

    /**
     * 这里就是查询booking表 - 并且keyword就是模糊查询的问诊的member的名字,返回的是booking的ID
     *
     * @param start   开始时间
     * @param end     结束时间
     * @param keyword 模糊查询member名字
     * @return
     */
    List<String> getIdConsultationHistory(@Param("start") Date start, @Param("end") Date end, @Param("keyword") String keyword, @Param("doctorId") String doctorId);

    List<ConsultantsMakeVo> getPassHistoryConsultantsPaging(@Param("memberId") String memberId, @Param("pageIndex") String pageIndex, @Param("pageSize") String pageSize, @Param("childId") String childId);

    List<DiagnosisMakeVo> findListDiagnosisByMemberId(@Param("memberId") String memberId,@Param("childId") String childId);

    List<GetPassHistoryConsultantsMakeVo> getPassHistoryConsultants(@Param("memberId") String memberId,@Param("childId") String childId);
    /**
     * 查询医生正在问诊的信息
     * @param booking
     * @return
     */
    ProfileVo.ActiveBooking selectActiveBooking(TblBooking booking);

    /**
     * 最近两次问诊的症状
     * @param patientMemId
     * @return
     */
    List<ProfileVo.ActiveBookingPassConsultation> selectPassConsultation(@Param("patientMemId")String patientMemId);

    List<HistoryConsultantsInitMakeVo> getPassHistoryConsultantsInit(@Param("memberId") String memberId, @Param("childId") String childId);

    /**
     * 医生端查询bookingInfo主数据
     * @param bookingId
     * @return
     */
    BookingInfoVo selectDoctorBookingInfo(@Param("bookingId")String bookingId);

    List<BookingInfoVo.Delivery_fee_detail> selectDoctorBookingInfoDeliveryFeeList(@Param("bookingId")String bookingId);

    List<BookingsMakeVo> getConsultationHistory(@Param("doctorId") String doctorId, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("keyword") String keyword);

    Integer getPatientServiceCountByDoctorId(@Param("doctorId") String doctorId);

    Integer getThisMonthServiceCountByDoctorId(@Param("doctorId") String doctorId);

    DoctorGetBookingDetailVo doctorGetBookingDetail(@Param("bookingId") String bookingId);

    List<MedicationsMakeVo> findMedicationsByBookingId(@Param("bookingId") String bookingId);

    List<AllergiesMakeVo> findAllergiesByBookingId(@Param("bookingId")String bookingId);

    List<LongtermsMakeVo> findLongtermsByBookingId(@Param("bookingId")String bookingId);

    List<MedicationReactionsMakeVo> findMedicationReactionsByBookingId(@Param("bookingId")String bookingId);

    List<MedicalServiceMakeVo> findMedicalServiceByBookingId(@Param("bookingId")String bookingId);

    List<DoctorGetBookingDetailProductPackagesVo> findProductPackagesByBookingId(@Param("bookingId")String bookingId);

    List<CdmpConditionPricingMakeVo> findCdmpConditionPricingByBookingId(@Param("countryId")String countryId,@Param("benefitId")String benefitId);

    List<BookingCdmpConditionMakeVo> findBookingCdmpConditionByBookingId(@Param("bookingId")String bookingId);

    List<BookingSelectedCdmpPackageMakeVo> findBookingSelectedCdmpPackageByBookingId(@Param("bookingId")String bookingId);

    /**
     *  获取历史咨询的booking数据
     * @param memberId 用户id
     * @param keyword 查询条件，目前查看postman只看到booking的code模糊查询，或许还有其余的字段模糊查询
     * @return
     */
    List<GetComboboxUpConsultVo.Consultants> getComboboxUpConsultFindHistoryByMemberId(@Param("memberId") String memberId,@Param("keyword") String keyword);


    TblBooking findById(@Param("bookingId") String bookingId);

    void updateStatusAndSubStatusByBookingId(@Param("bookingId") String bookingId,@Param("status") Integer status,@Param("subStatus") Integer subStatus);

    /**
     * 这个方法是根据bookingId将deeplink_id设置为null
     *
     * @param bookingId booking
     */
    void updateDeeplinkIdNullByBookingId(@Param("bookingId") String bookingId);

    Integer findCountByDoctorIdAndByStatus(@Param("doctorId") String doctorId);
}